﻿using SW2A311_Lib;
using System;

namespace Server
{
    class EventDrivenShare
    {
        #region Dataindkapsling
        /// <summary>
        /// Indkapsling til ChatMessageChange event
        /// </summary>
        public class ChatMessageArgs : EventArgs
        {
            public ChatMessageArgs(String ChatMessageIn)
            {
                this.ChatMessage = ChatMessageIn;
            }

            public readonly string ChatMessage;
        }
        #endregion

        #region Properties
        private string _chatMessage;
        public string ChatMessage
        {
            get { return _chatMessage; }
            set
            {
                _chatMessage = value;
                ChatMessageChanged(new ChatMessageArgs(value));
            }
        }
        #endregion

        #region Event
        /// <summary>
        /// Event der reagere på ændring af propertien Encapsulation
        /// </summary>
        /// <param name="e">Inputtet der sendes videre til alle subscribers</param>
        public event EventHandler<ChatMessageArgs> ChatMessageChange = delegate { };

        protected virtual void ChatMessageChanged(ChatMessageArgs e)
        {
            if (ChatMessageChange != null)
                ChatMessageChange(this, e);
        }

        #endregion

    }
}
